<?
require_once('includes/common.php');

function show_anons(){
	global $anonsSide;
	global $lang;
	$anons = new AnonsBO();
	$perpage = 5;
	$cond = "";
	if( ($anonsSide=='right')||($anonsSide=='left') ){
		$cond = "AND anons_SiteSide='".(($anonsSide=='left')?"0":"1")."' ";
	}
	$where = " if( DATE_ADD(anons_Date, INTERVAL anons_TTL DAY)=anons_Date, ".
		 "anons_Date < now(), ".
		 "anons_Date < now() AND DATE_ADD(anons_Date, INTERVAL anons_TTL DAY)>now() ) ".$cond;
	$anons->visible = '1';
	OB_START();
	$count = $anons->getCount($where);
	OB_END_CLEAN();

//		$article = new ArticleBO();
//		$article->langID = CURRENT_LANGUAGE_ID;
//		$anons->LeftJoin($article);
	OB_START();
	$count_res = $anons->GetCount($where);
	$anons->Load(0, $perpage, array($anons->fields['position'] => "0"),$where);
	OB_END_CLEAN();

 if($count_res>0){?>
<!-- ANONS -->
<tr height="8"><td></td></tr>
<tr><td valign="top" align="center" height="1">
	<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top" style="padding: 0 0 0 2"><?
  while($anons->Next()){
	// Load article
	$a = new ArticleBO();
	$a->id = $anons->caption_article_id;
	$a->langID = '1';
	OB_START();
	$a->Load(0,1);
	OB_END_CLEAN();
	if($a->Next()){ 
	  $show_more = false;
	  if(($anons->article_id>0)&&($anons->is_art_exist($anons->article_id)==true) ){ $show_more = true; }
	  echo show_anons_block( $anons->title, $a->content, $show_more, $anons->article_id );
	} //if
  }//while
?>
	</table>
</td></tr>
<?
 } // if($count_res>0)

} // function show_anons()
?>